package model;

import parserXMI.Codable;
import parserXMI.Typable;
import parserXMI.Type;
import parserXMI.Types;

public class Literal implements Typable, Codable{
	private Object value;
	private Type type;
	private String code;
	
	public Literal (Object value, Type type){
		this.value = value;
		this.type = type;
	}
	
	public Literal (Object value, String type){
		this.value = value;
		this.type = Types.getType(type);
	}
			
	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	@Override
	public void setType(Type type) {
		this.type = type;
		
	}

	@Override
	public Type getType() {
		return this.type;
	}
	
	public String toString(){
		return getValue().toString();
	}

	@Override
	public void gen3Address() {
		// TODO Auto-generated method stub
	}

	@Override
	public String genObjectCode() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getAddr() {
		return getValue().toString();
	}

	@Override
	public void setAddr(String temp) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Label getNext() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setNext(Label next) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String getCode() {
		if(this.code == null || this.code.equals(""))
			setCode(""+getValue());
		return this.code;
	}

	@Override
	public void setCode(String code) {
		this.code = code;
	}

}
